﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Routing;
using System.Web.Mvc;

namespace Enter.Mvc.Statistics.Route
{
	public class ImgRoute : RouteBase
	{
		private string[] urls;
		public ImgRoute(params string[] targetUrls)
		{
            urls = targetUrls;
        }

		public override RouteData GetRouteData(System.Web.HttpContextBase httpContext)
		{
			RouteData result = null;
			string requestedURL =
				httpContext.Request.AppRelativeCurrentExecutionFilePath + httpContext.Request.PathInfo;
			requestedURL = requestedURL.Substring(2).Trim('/');
			if (requestedURL.Contains(urls.ToArray().GetValue(0).ToString()))
			{
				result = new RouteData(this, new MvcRouteHandler());
				result.Values.Add("controller", "Img");
				result.Values.Add("action", "Index");
				result.Values.Add("p", requestedURL);
			}
			return result;
		}

		public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
		{
			throw new NotImplementedException();
		}
	}
}
